由于新的文件夹结构,在 Linux 上的 Intellij IDEA 中将 Java 9 正确设置为 SDK

您所在的位置:网站首页 idea 更改jdk 由于新的文件夹结构,在 Linux 上的 Intellij IDEA 中将 Java 9 正确设置为 SDK

由于新的文件夹结构,在 Linux 上的 Intellij IDEA 中将 Java 9 正确设置为 SDK

2023-03-27 03:30| 来源: 网络整理| 查看: 265

.主要区别: Linux 版本:他们使用的是 Mint 18,而我使用的是 Debian Stretch. 在撰写本文时,OpenJDK 是 repo 中的最新版本:9~b181-4~bpo9+1.即使是相同的版本,它在我的情况下仍然不起作用.

另一个可能的重复:intellij idea没有看到java 9 标准类

虽然我不明白评论中的答案.尝试为 JDK(9 和 1.9)设置不同的名称,但它仍然没有显示模块而不是类路径,并且类路径仍然为空.

解决方案

当前的 debian 二进制包 openjdk-9-jre-headless 9~b181-4 包含错误编译的 lib/jrt-fs.jar 文件.idea youtrack 和 ubuntu 启动板.

正如此处所示:>

可能的原因:lib/jrt-fs.jar 中的类由 Java 9 编译,带有选项-source 8″/target 8″.它们应该使用–release 8″选项编译(或通过 Java 8)

一种临时解决方法可能是将 /usr/lib/jvm/java-9-openjdk-amd64/lib/jrt-fs.jar 替换为 Oracle JDK.您也可以尝试使用建议的选项–release 8“重新编译 openjdk-9 源.

无论如何,我建议在上面的链接上对这个问题进行投票,以吸引开发团队的更多关注.

Before you write me off, please consider that neither of these are answers to my question:

How to setup SDK in IntelliJ IDEA? How do I change the IntelliJ IDEA default JDK?

In IntelliJ IDEA 2017.2.6, attempting to add JDK9 as an SDK passes but does not work as the classpaths end up empty. Steps to reproduce:

Open ‘Add new SDK dialog’ (go to Project Settings > Project > Project SDK > New > JDK) Select JDK 9 Passes, but if you look under SDK > JDK9 classpaths are empty and your code errors out due to base classes not being found. See image:

In IntelliJ IDEA 2017.3 EAP you get an error about JDK classes not being found. See images below:

Open ‘Add new SDK dialog’ (go to Project Settings > Project > Project SDK > New > JDK) Select JDK 9 Should pass, but produces error popup

Command line compilation of HelloWorld example with jdk9 works as expected.

EDIT: Found an almost-duplicate: Intellij IDEA 2017.2 can’t add openjk 9 on Linux Mint 18. Key differences:

Linux version: they’re using Mint 18, and I’m using Debian Stretch. OpenJDK is the latest from the repo at the moment of writing: 9~b181-4~bpo9+1. Even though is the same version, it still does not work in my case.

EDIT: Another possible duplicate: intellij idea does not see java 9 standard classes

I did not understand the answer from the comments though. Tried setting different names for JDK (9 and 1.9) but it still did not show modules instead of classpaths and classpaths remained empty.

解决方案

Current debian binary package openjdk-9-jre-headless 9~b181-4 contains incorrectly compiled lib/jrt-fs.jar file. There are 2 filed issues separately on both idea youtrack and also ubuntu launchpad.

As it is indicated here:

Probable reason: Classes in lib/jrt-fs.jar were compiled by Java 9 with options “-source 8″/”target 8”. They should be compiled with “–release 8” option instead (or by Java 8)

A temporary workaround may be replacing /usr/lib/jvm/java-9-openjdk-amd64/lib/jrt-fs.jar with the one from Oracle JDK. You may also try to recompile the openjdk-9 source using the advised option “–release 8“.

Anyway I advice to vote up this issue on the above link to attract more attention by dev team.

这篇关于由于新的文件夹结构,在 Linux 上的 Intellij IDEA 中将 Java 9 正确设置为 SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,WP2



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3